package com.xm.xmapp.adapter;

import java.util.ArrayList;

import android.app.Activity;
import android.support.v4.content.ContextCompat;
import android.view.View;

import com.xm.xmapp.R;
import com.xm.xmapp.app.MyAppcation;
import com.xm.xmapp.base.MyBaseAdapter;
import com.xm.xmapp.base.ViewHolder;
import com.xm.xmapp.customview.CustomLayoutText;
import com.xm.xmapp.response.bean.ResponseRefundDetails;
import com.xm.xmapp.tools.StringTools;

public class AccountRecordRefundAdapter extends MyBaseAdapter<ResponseRefundDetails> {

	private int firstPosition;

	public void setFirstPosition(int firstPosition) {
		this.firstPosition = firstPosition;
	}

	public AccountRecordRefundAdapter(ArrayList<ResponseRefundDetails> list, Activity activity, int layoutId) {
		super(list, activity, layoutId);
	}

	@Override
	public void setValues(ViewHolder holder, ResponseRefundDetails t, int position) {

		CustomLayoutText cl_pay_type = (CustomLayoutText) holder.getView(R.id.cl_pay_type);
		CustomLayoutText cl_pay_money = (CustomLayoutText) holder.getView(R.id.cl_pay_money);
		cl_pay_money.setText2(t.return_money);
		cl_pay_type.setText2(StringTools.getPayWay(t.return_way_type));

		if ((position == 0 && t.handle == 1) || (position == firstPosition)) {
			holder.getView(R.id.tv_status).setVisibility(View.VISIBLE);
		} else {
			holder.getView(R.id.tv_status).setVisibility(View.GONE);
		}

		switch (t.handle) {
		case 0:

			break;
		case 1:
			cl_pay_money.getTextView2()
					.setTextColor(ContextCompat.getColor(MyAppcation.getMyAppcation(), R.color.green_color_text));
			holder.setText(R.id.tv_status, "退款成功");

			break;
		case 2:
			cl_pay_money.getTextView2().setTextColor(
					ContextCompat.getColor(MyAppcation.getMyAppcation(), R.color.red_text_color));
			holder.setText(R.id.tv_status, "退款失败");

			break;

		default:
			break;
		}

	}

}
